#ifndef _IF_V_H_
#define _IF_V_H_

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "aos/list.h"
#include <sys/types.h>
#include "mm_config.h"
#include "drv_isp.h"
#include "sensor_common.h"
#include "wrapper.h"
#include "board.h"
#include "face_result.h"
#include "rectify_param.h"

#define JPG_REGISTER_MAX_SIZE   2048*2048*2
#define JPG_REGISTER_MIN_SIZE   (48*48)/2
#define CROP_PIC_WIDTH 360
#define CROP_PIC_HIGHT 640

#define LIVE_3D_ENABLE 0

#define IR2_DEP_X2_LEN 640*360*2*2
#define IR2_DEP_Y2_LEN 640*360*2
#define IR2_DEP_TAB2D_LEN 4096*2

#define QSPI_IR2_DEP_X2_OFFSET 0x100000
#define QSPI_IR2_DEP_Y2_OFFSET QSPI_IR2_DEP_X2_OFFSET+IR2_DEP_X2_LEN
#define QSPI_IR2_DEP_TAB2D_OFFSET QSPI_IR2_DEP_Y2_OFFSET+IR2_DEP_Y2_LEN


enum {
	IFV_PAYMENT_SCENARIO,
	IFV_ENTRANCE_SCENARIO,
	IFV_LOCK_SCENARIO
};

enum {
	IFV_SENSOR_TYPE_IR_LEFT,
    IFV_SENSOR_TYPE_RGB,
	IFV_SENSOR_TYPE_IR_RIGHT,
	IFV_SENSOR_TYPE_MAX
};


typedef struct _list_t
{
    struct _list_t *next;
    struct _list_t *prev;
} ifv_list_t;

typedef struct FaceAeParam
{
    uint32_t setpoint_step;
    uint32_t setpoint_min;
    uint32_t setpoint_max;
    uint32_t luma_min[ISP_NUM];
    uint32_t luma_max[ISP_NUM];
    uint32_t trigger_frame_cnt;
}FaceAeParam_S;

typedef struct data_flow_func_control{
	int 	source;			//sensor rgb,ir,
	int 	sink;			//display, 
	int     preview_mode;

	bool    mask_enable;
	bool    guidefilter_enable;
	bool	detect_vis_enable; 
	bool	detect_nir_enable; 
	bool 	live_vis_enable;
	bool 	live_nir_enable;
	bool    live_depth_face_enable;
	bool    live_depth_luma_enable;

	bool	jpeg_proc_enable;

	bool    recog_vis_enable;
	bool    recog_ir_enable;

	bool    display_enable;
	bool    display_ir;
	bool    display_vis;
	
	bool    cat_eye_enable;
	// Sensor stream type
	int 	source_ir_left;  //by camera view:default
	int     source_ir_right; //by camera view
	int     source_ir_tof;
	int     source_vis;
	int     source_spk;

	int 	depth_doubleIr_enable;

	int     register_vis;
	int     register_nir;
	int     register_live;
	int     register_pic;

	TSM_VIDEO_RES_TYPE_E   	enResIR;
	TSM_VIDEO_RES_TYPE_E   	enResRGB;

    int     ck805_enable;
	float   facematch_thres;
    bool    save_ae_enable;
    bool    face_ae_ir;
    FaceAeParam_S           ir_faceAE_param;
	bool	reco_luma_adjust_ir;
	
	int     mid_reset_flag;
	int     mid_face_reset_flag;
	int     mid_debug_mode_flag;
	int     sensetime_protocol_enable;

	uint32_t max_face_num;
    int     mi_data_ayout;
}data_flow_func_control_t;

typedef struct aie_para_control{
	int 	pic_width;
	int 	pic_higth;

	float   faceDetectThres;
    float   faceNirDetectThres;
    float   faceMatchThres;
    float   living3DThres;         /* 3d */
    float   livingNirThres;        /* 2d */
    float   livingVisNcThres;      /* 1d */
    float   livingVisThres;        /* 1d */
    float   maleThres;             /* gender */
    float   headPoseThresX;         /* head pose */
    float   headPoseThresY;         /* head pose */

}aie_para_control_t;

typedef struct g_variable_control{
	int 	registerIDStartNo;
	int 	g_sensorCalState;
	int     g_read_pic_by_usb_flag;
	int 	g_calibration_flag;
	int 	g_calib_estimate_flag;
	int 	g_calibration_loop_count;
	int 	g_calib_not_save_flag;
	float 	g_calib_estimate_dif_LR2;
	uint16_t *ir2_dep_x2;
	uint16_t *ir2_dep_y2;
	uint16_t *ir2_dep_tab2d;
	
}g_variable_control_t;



typedef struct living_detection_config{
		float living_1D_thres;
		float living_2D_thres;
		float living_3D_thres;
	
}living_detection_config;


typedef struct face_detect_config{
		int 	vis_detect_enable;
		float 	vis_detect_thres;
		int 	ir_detect_enable;
		float 	ir_detect_thres;
	
}face_detect_config; 


typedef struct identifyID{
	int id;
	int sec_id;
}identifyID;

typedef struct register_info
{
	identifyID *info;
	int pic_type; //ir/rgb
	int pic_w;
	int pic_h;
	int pic_mode; //JPG/RAW
	int pic_size;
	unsigned char *buff;
	
}if_v_register;

typedef struct query_info
{
	ifv_list_t		head;
	identifyID *info;

}if_v_query;


typedef void (*event_handler)(int event, void *data);


typedef struct app2if_v_cb{
	ifv_list_t 	head;
	int event_type;
	identifyID *info;
	int feedback;
	unsigned char *pBuff;
	void *private_data;
}app2if_v_cb;

typedef struct {
	int cmd_type;
	int flag;
	int state;
	dlist_t linked_list;
}cmd2openmax_list;

typedef struct {
	int flag;
	int state;
	if_v_register jpeg_reg_info;
	dlist_t linked_list;
}cmd2openmaxJpeg_list;

#if defined (MINI_STRUCTURE_LIGHT_MODULE)
typedef struct {
	uint32_t flag;
	uint32_t SN;
	double calibPara;
	uint8_t basePic[450*1024];
}sensor_para_t;
#else
typedef struct {
	uint32_t flag;
	uint32_t SN;
	double calibPara;
	uint8_t basePic[225*1024];
}sensor_para_t;

#endif

enum{
 	 VIS_STREAM_DECT_EVENT,
 	 VIS_CAP_DECT_EVENT		
};

enum{ 
 	 IR_CAP_IMAGE_SUCCESS_EVENT,
 	 SPK_CAP_IMAGE_SUCCESS_EVENT
};

enum{
	IFV_REGISTER_MODE_NONE,
	IFV_REGISTER_MODE_PIC_JPG,
	IFV_REGISTER_MODE_SENSOR_RGB,
	IFV_REGISTER_MODE_SENSOR_IR,
    IFV_REGISTER_MODE_PIC_RAW,
    IFV_REGISTER_MODE_PIC_IR_RAW,
};

enum event2client_types{
	 SPK_IMAGE_GET_SUCCESS_EVENT,
	 RGB_IMAGE_GET_SUCCESS_EVENT,
	 RGB_QUALITY_RESULTS_EVENT,
	 IR_QUALITY_RESULTS_EVENT,
	 LIVING_1D_RESULTS_EVENT,
	 LIVING_2D_RESULTS_EVENT,
	 RGB_PROCESS_RESULTS_EVENT,
	 IR_PROCESS_RESULTS_EVENT,
	 RECOGNIZE_RESULTS_EVENT,
	 REGISTER_RESULTS_EVENT
};


enum app2ifv{
	 APP2IFV_REGISTER_CMD,
	 APP2IFV_REGISTER_EVENT,
	 APP2IFV_RECOGNIZE_CMD,
	 APP2IFV_RECOGNIZE_EVENT,
	 APP2IFV_REGISTER_UART_CMD,
	 APP2IFV_SNAP_IR_CMD,
	 APP2IFV_SNAP_SPK_CMD,	 
	 APP2IFV_SNAP_RGB_CMD,
	 APP2IFV_DEL_USER_CMD,
	 APP2IFV_DEL_USER_RANGE_CMD,
	 APP2IFV_DEL_ALL_USERS_CMD,
	 APP2IFV_GET_USER_INFO_CMD,
	 APP2IFV_GET_ALL_USERS_ID_CMD,
	 APP2IFV_SET_THRESH_CMD,
	 APP2IFV_QUERY_CMD,
	 APP2IFV_ISP_START_SET,
	 APP2IFV_ISP_STOP_SET,
	 APP2IFV_SNAPSHOT_MODE_3IN1,
	 APP2IFV_STREAM_START,
	 APP2IFV_STREAM_STOP,
	 APP2IFV_SNAPSHOT_MODE_DONE,
	 APP2IFV_CALIBRATION_CMD,
	 APP2IFV_CALIB_ESTIMATE_CMD,
};


enum {
	APP2IFV_CMD_STATE_NONE,
	APP2IFV_RECOGNIZE_CMD_STATE_IR_ENTRY,
    APP2IFV_RECOGNIZE_CMD_STATE_RIGHT_IR_ENTRY,
	APP2IFV_RECOGNIZE_CMD_STATE_SPK_ENTRY,	
	APP2IFV_RECOGNIZE_CMD_STATE_COMPLETE,
	APP2IFV_RECOGNIZE_CMD_STATE_RECO,
	APP2IFV_REGISTER_CMD_STATE_INIT,
	APP2IFV_REGISTER_CMD_STATE_COMPLETE,
	APP2IFV_REGISTER_CMD_BATCH_START,
	APP2IFV_REGISTER_CMD_BATCH_COMPLETE,
	APP2IFV_CALIBRATION_CMD_STATE_ENTRY,
	APP2IFV_CMD_INVALID
};

enum{
	UVC_SPK_IR_DEPTH_MODE,
    UVC_RGB_IR_SPK_MODE,
	UVC_IR_DEPTH_MODE,
	UVC_DUAL_IR_MODE,
	UVC_RGB_MODE,
	UVC_CAP_MODE,
	UVC_NONE_MODE
};

enum{
	ISP_IR_BUF_IDX_0,		
	ISP_IR_BUF_IDX_1,		
	ISP_IR_BUF_IDX_2
};
enum{
	ISP_SPK_BUF_IDX_0,		
	ISP_SPK_BUF_IDX_1,		
	ISP_SPK_BUF_IDX_2		
};

enum{
	ISP_IR_LEFT_BUF_IDX_0,		
	ISP_IR_LEFT_BUF_IDX_1,
	ISP_IR_LEFT_BUF_IDX_2				
};

enum{
	ISP_IR_RIGHT_BUF_IDX_0,		
	ISP_IR_RIGHT_BUF_IDX_1,
	ISP_IR_RIGHT_BUF_IDX_2			
};

enum{
	ISP_RGB_BUF_IDX_0,		
	ISP_RGB_BUF_IDX_1,		
	ISP_RGB_BUF_IDX_2,
	ISP_RGB_BUF_IDX_3,		
	ISP_RGB_BUF_IDX_4,		
	ISP_RGB_BUF_IDX_5		
};

typedef struct {
	int src_type;
	unsigned char *name;
}openMaxSrcDesc;

#define EV_IFV 	0xaabbccdd
#define IFV_CMD_REGISTER 1


typedef struct _ifv_msg_pkg_t {
    unsigned int cmd;
    unsigned int value;
	void 		*pData;
} ifv_msg_pkg_t;

typedef struct if_v_sema{
	void *hdl;
	int type;
}if_v_sema_t;

/*
#define OPENMAX_SOURCE_VIS_EVENT	0x0
#define OPENMAX_SOURCE_IR_CAP_EVENT		0x1


#define OPENMAX_SOURCE_REQUEST_IMAGE_EVENT	0x0
#define OPENMAX_SINK_SET_IMAGE_TO_DISP		0x1
#define OPENMAX_IR_SPK_LED_TOGGLE			0x2
#define OPENMAX_VISIBLE_REGISTER_EVENT     	0x2
#define OPENMAX_IR_RECOGNIZE_EVENT     		0x3

#define OPENMAX_RECOGNIZE_RESUTLES_EVENT    0x4
#define OPENMAX_DOUBLE_IR_RECOGNIZE_EVENT   0x5


#define OPENMAX_VIS_DETECT_EVENT 			0x08
#define OPENMAX_SOURCE_SPK_CAP_EVENT		0x09
*/
typedef enum ifvOmxEventType_e{
    OPENMAX_SOURCE_VIS_EVENT,
    OPENMAX_SOURCE_IR_CAP_EVENT,
    OPENMAX_VISIBLE_REGISTER_EVENT,
    OPENMAX_IR_RECOGNIZE_EVENT,
    OPENMAX_DOUBLE_IR_RECOGNIZE_EVENT,
    OPENMAX_TOF_IR_RECOGNIZE_EVENT,
    OPENMAX_FACE_RECOG_EVENT,
    OPENMAX_3D_DETECT_EVENT,
    OPENMAX_VIS_DETECT_EVENT,
    OPENMAX_SOURCE_SPK_CAP_EVENT,

    OPENMAX_MAX_EVENT
}ifvOmxEventType_t;



#define IFV_PIC_REGISTER_ADR_TEMP          MM_MIPI2DMA_BUF1

#define IFV_CLI_DEBUG       "ifv_cli_debug"
#define IFV_IR_FILE_INDEX   "ifv_ir_file_index"
#define IFV_RGB_FILE_INDEX  "ifv_rgb_file_index"

#define IFV_RUNNING_TEST_MODE       "ifv_test_mode"
#define IFV_USB_FIRMWARE_ENABLE       "ifv_usb_firmware_enable"
#define IFV_USB_PIC_SAVE_ENABLE       "ifv_usb_pic_save_enable"
#define IFV_SET_FACEMATCHTHRES      "ifv_set_facematchthres"
#define IFV_SET_FACEMATCHTHRES_FLAG      "ifv_set_facematchthres_flag"
#define IFV_RUNMODE_COVER      "ifv_runmode_cover"
#define IFV_AIERESULT_PRINT_TIMES      "ifv_aieresult_print_times"
#define IFV_UVC_PREVIEW_MODE      "ifv_uvc_preview_mode"

#define IFV_FILE_IR_MAX_INDEX 100
#define IFV_FILE_RGB_MAX_INDEX 100
#define IFV_IR_PIC_WIDTH 360
#define IFV_IR_PIC_HIGHT 640
#define IFV_IR_PIC_SIZE (IFV_IR_PIC_WIDTH*IFV_IR_PIC_HIGHT)
#define IFV_IR_BASE_ADDR MM_IMG_ISP0_BUF1
#define IFV_RGB_PIC_WIDTH ISP_OUTPUT_WIDTH
#define IFV_RGB_PIC_HIGHT ISP_OUTPUT_HIGHT
#define IFV_RGB_PIC_SIZE (IFV_RGB_PIC_WIDTH*IFV_RGB_PIC_HIGHT)
#define IFV_RGB_BASE_ADDR MM_MIPI2DMA_BUF1
#define IFV_IR_DIR_ROOT FS_ROOT_PATH"/IMAGE_IR"
#define IFV_RGB_DIR_ROOT FS_ROOT_PATH"/IMAGE_RGB"
#define IFV_CLI_THRES_2D       "ifv_cli_thres_2d"
#define IFV_CLI_THRES_3D       "ifv_cli_thres_3d"
#define IFV_CLI_THRES_RECOG    "ifv_cli_thres_recog"
#define IFV_CLI_THRES_RECOG_MASK    "ifv_cli_thres_recog_mask"
#define CALIBRATION_KV_STATE    "ifv_cal_state"

#define IFV_RECOG_REG_LOOP_COUNT 2
#define IFV_DOUBLE_IR_CALIB_LOOP_COUNT 5


#define IFV_CLI_IMAGE_MODE     "ifv_cli_image_mode"

typedef struct _ifvEventHandler{
		ifvOmxEventType_t openmax_event_type;
		event_handler ifv_cb;
}ifvOpenmaxEventHandler_t;


#define ISP_IR_STREAM_STANDBY 0
#define ISP_IR_STREAM_RESUME 1



enum {
	IFV_MSG_EXCESSIVE, 
	IFV_MSG_MSGDUMP, 
	IFV_MSG_DEBUG, 
	IFV_MSG_INFO, 
	IFV_MSG_WARNING, 
	IFV_MSG_ERROR
};

enum{
	IFV_SENSOR_INIT_IR,
	IFV_SENSOR_INIT_RGB,
	IFV_SENSOR_INIT_NONE
};


typedef enum {
	SCENE_INVALID = 0,
	SCENE_LOCK,
	SCENE_OUTDOOR,
	SCENE_INDOOR,
	SCENE_BOTTOM
} MeanLumaSceneStatus_e;

typedef struct {
	uint8_t thd_max_h;
	uint8_t thd_max_l;

	uint8_t thd_min_h;
	uint8_t thd_min_l;

	TSM_SENSOR_EXPO_E scene;
} MeanLumaSceneJudgeConfig_s;


typedef int (*sensorScenarioSetup)(void);
typedef int (*sensorScenarioCheck)(int sensor_id, void *cfg);


typedef struct {
	int scenario_type;
	int mipi_id;
	int isp_id;
	int light_type;
	bool live_3D_enable;	
	sensorScenarioSetup reconfig;
    bool rotate;
    bool v_flip;
    bool h_flip;
}sensorScenario_t;


#define	USERCMDRECOGNIZERESULT_NONE				0xFF

typedef  void (*PUSERFUNCMD)(void *pBuff); 
typedef struct CmdEntry
{
    PUSERFUNCMD pfuncmd;    
    unsigned char cHelp[128];
}UserCmdCB;

typedef struct FaceBox {
    float xmin;
    float ymin;
    float xmax;
    float ymax;
} FaceBox_S;

typedef struct CmdRegisterCBinfo
{
    int result;    //success 0
    int id;
	TsmFaceResult *tp;
}CmdRegisterCBinfo_S;

typedef struct CmdRecognizeCBinfo
{
    int result;    //success 0
	int flag;
    int id;
	FaceBox_S box;
    float pose[3];
	TsmFaceResult *tp;
}CmdRecognizeCBinfo_S;

typedef struct CmdPoseCBinfo
{
    int result;    //success 0
	FaceBox_S box;
}CmdPoseCBinfo_S;

typedef struct ifv_sensor_func_t
{
    int                (*pGetExpoPara)();
    int                (*pSetExpoPara)();
    int                (*pSetSpkStrobePara)();
}ifv_sensor_func_s;

typedef struct ifv_face_ae_info_t {
	uint32_t face_ae_ir;
    bool nir_box_ready;
    TsmFaceBox nirBox[ISP_NUM]; // size = nFace * sizeof(TsmFaceBox)
	int32_t nirFace[ISP_NUM];
    bool    face_ae_done;
    uint32_t meanLuma_face[ISP_NUM];
    uint32_t meanLuma_isp[ISP_NUM];
    uint32_t loop_counter;
	uint32_t inProcess;
} ifv_face_ae_info_s;

#define EVENT_IFV_COGNIZE_PROC 0x1

#ifdef BCTC_TEST
enum {
	BCTC_QA_ERROR_RESOLUTION = 0,
	BCTC_QA_ERROR_COVER,
	BCTC_QA_ERROR_INTERPUPILLARY_DISTANCE,
	BCTC_QA_ERROR_FUZZY,
	BCTC_QA_ERROR_EXPRESSION,
	BCTC_QA_ERROR_ANGLE,
	BCTC_QA_ERROR_LUX,
	BCTC_QA_ERROR_MULTIPLE_FACE,
};

typedef struct BctcSaveImage
{
	uint8_t *faceImage;
	uint8_t result;
	uint16_t xmin;
	uint16_t ymin;
	uint16_t xmax;
	uint16_t ymax;
}Bctc_s;
#endif
/*******************************************************/
enum {
	FACE_RESULT_SUCCESS = 0,
	FACE_RESULT_NO_FACE = 1,
	FACE_RESULT_FACE_MORE = 2,
	FACE_RESULT_BAD_POSTURE = 3,
	FACE_RESULT_FUZZY = 4,
	FACE_RESULT_COVER = 5,
	FACE_RESULT_LIVING_NIR_FAILED = 6,
	FACE_RESULT_LIVING_3D_FAILED = 7,
	FACE_RESULT_NOT_MATCH = 8,
	FACE_RESULT_REPEAT = 9,
}faceResult_e;

enum {
	IFV_RUNNING_STATE_NONE,
	IFV_RUNNING_STATE_STREAM,	
	IFV_RUNNING_STATE_SNAP_RGB,
	IFV_RUNNING_STATE_SNAP_IR,
	IFV_RUNNING_STATE_SNAP_SPK,
};

extern char *g_ifv_pic_register;
extern uint32_t g_recog_repeat_interval;
extern aos_timer_t timer_recog_ratelimit;
extern uint32_t g_recog_repeat_suppress;
extern uint32_t g_curr_recog_id;
extern uint8_t *faceFeature;
extern uint8_t *faceMaskFeature;
extern data_flow_func_control_t g_ifv_flow_cfg;
extern sensorScenario_t TX510_sensor_defConfig[];
extern ifv_sensor_func_s g_ifv_sensor_func; 
extern uint32_t g_ulIfvDebugEnable;
extern int g_sys_init_done;
extern data_flow_func_control_t g_app_flow_cfg;

#define	PASSLOG_TEST_VERSION			(1)
extern uint8_t *g_tx_vis_buff;
extern bool g_tx_enable_flag;
extern int g_reco_result;
extern int g_reco_id;
extern bool g_passlog_en;
extern ifv_face_ae_info_s g_face_ae_info;


int scene_judge_meanluma( int32_t idx, MeanLumaSceneJudgeConfig_s *cfg );
void if_vGetMeanluma(int32_t idx, uint32_t *MeanLuma);
int if_vReConfigSensorLed();

bool configSensor(int sensor_type);
bool configLcd(int led_type);
bool configDataFlow(data_flow_func_control_t *config);
bool configModeOne2One();
bool if_vConfigSensorBufIO();
bool if_vConfigSensor(Sensor_e type);
void if_vSetVisDetect(bool flag);
void if_vSetVisReco(bool flag);
bool if_vInitial_vis();
bool if_vInitial_iva();
bool if_vInitial_ff();
int	ifv_getIspExpValueKv(float *ir_expo);
//int	ifv_getIspSetPointValueKv();
int ifv_getFaceXYValueKv();
int32_t if_vGetRotateLuma(int32_t idx, uint8_t aec_exp_means[][5]);
void if_vGetFaceMeanluma_sw(int32_t idx, TsmFaceBox *nirBox, int32_t nFace, uint32_t *MeanLuma, uint32_t doubleIrBufNum);
bool if_vInitIal_IR_AE();
int ifv_Initial_visbuffer();
bool if_vInitial(UserCmdCB *cb, data_flow_func_control_t flow_cfg);
int registerEventCallback(void *ctx, event_handler callback);
void if_v_source_spk_event_callback(int event, void *data);
void if_v_source_ir_event_callback(int event, void *data);
void if_v_source_vis_event_callback(int event, void *data);
void if_v_Register_vis_event_callback(int event, void *pData);
void if_v_Recognize_ir_event_callback(int event, void *pData);
void if_v_Recognize_double_ir_event_callback(int event, void *pData);
void tof_Recognize_event_callback(int event, void *pData);


void if_v_sink_event_callback(int event, void *data);
void if_WebBulkTranSet(void);
void if_WebBulkTranClear(void);
void if_WebBulkTranferSignal(void);
void if_WebBulkTranferWait(void);
void if_WebRegSyncSignal(void *pBuff);
int if_if_WebRegSyncWait(void);
int if_vWebRegister(if_v_register * register_info);
void if_vWebRecogRecordTask(void);
// int if_vWebRecogRecord(int ff_id);
// void if_vWebRecogRecordSingal(int ff_id);
int if_vWebRecogRecord(int result, int ff_id);
void if_vWebRecogRecordSingal(int result, int ff_id);
bool if_vRegister(if_v_register * register_info);
bool if_vQuery(if_v_query * query_info);
bool if_vDelete(if_v_query * delete_info);
bool if_vSensorLedControl(int sensorID, int led_type); //ir/spk
bool if_vFaceRecogEvent(int sensorID, void *pData); //ir/spk
bool if_v3DdetectEvent(int sensorID, void *pData); //ir/spk

bool if_vVisDetectEvent(int event, void *pData);

void if_v_visible_event_callback(int event, void *data);
int if_vReadDataFromISP(int isp_id, int *outType);
void if_vNotifyIspData(int isp_id);
int if_vIrStreamPauseResume(int action, int mipi_id, int isp_id, int led_type);
void if_vRecogIrSemaPost(int result);
int ifvCmd2OpenmaxLookup(int list_type, int *cmd);
int cmd2Openmax_wait_sema();
void cmd2Openmax_post_sema();
void ifv_printf(int level, const char *fmt, ...);
void if_vIspBufferSetMap(int type);

void if_vNotifyIspMiData(int isp_id);
int if_vReadIspMiData(int isp_id);

int if_GetOpenmaxCurrentIrMode();
int if_GetOpenmaxCurrent3DMode();
void if_vGetIrSpkSnapShot(int mipi_id, int isp_id, int led_type, unsigned char *pBuffer);
int if_vRgbStreamPauseResume(int action );
void if_vFlowStateReset(int idx);

int if_v_cli_register();

int if_vDel(int id);
int if_vDelRange(uint16_t idS, uint16_t idE);
int if_vDelAll(void);
bool if_vGetUsrInfo(uint16_t user_id);
bool if_vGetAllUsrID(void);
bool if_vSetThreshLevel(uint32_t match_thresh, uint32_t living_thresh);
int img_cli_register(void) ;
int if_vGetRegisterMode();
int if_vSetRegisterMode(int mode);

void if_vGetRGBSnapShot(unsigned char *pBuffer, int len);
int ifv_post_msg(ifv_msg_pkg_t msg);

char *ifvGetRegisterNameByID(uint32_t ff_id);
void ifvSetRegisterName(uint32_t ff_id, char *name);

int if_vThres2dGet(float *thres);
int if_vThres2dSet(float thres);
int if_vThres2dSetDefault();
int if_vThresRecoGet(float *thres);
int if_vThresRecoSet(float thres);
int if_vThresRecoSetDefault();
int if_vThresMaskRecoGet(float *thres);
int if_vThresMaskRecoSet(float thres);
int if_vThresMaskRecoSetDefault();
uint32_t ifvGetFlowState();

void timer_recog_ratelimit_cb(void *arg,void *arg2);
void face_recognize_loop(void *arg);
int vis_image_channel_set(imageChannel_t *image_ch, bool isp_bypass, 
                                uint32_t i2c_num, uint32_t i2c_slave_addr);
int ir_image_channel_set(imageChannel_t *image_ch, bool isp_bypass, 
                                uint32_t i2c_num, uint32_t i2c_slave_addr);
void isp_res_map(image_res_e      res, uint32_t *width, uint32_t *height);
void isp_format_map(image_format_e format, uint32_t *isp_format);
uint32_t load_file(unsigned char **buff, const char *path);
extern uint8_t* iva_facereco_ir_get_buffer(uint32_t port_index, uint32_t buf_index);
extern void omx_thres_recog_set(float thres);
extern void omx_thres_mask_recog_set(float thres);
//extern void if_v_get_current_ir_face_luma(uint32_t *luma);
//extern void if_v_get_current_ir_setpoint(float *setpoint);
//extern void if_v_getIrImageBuffer(uint32_t isp_idx, char **imgBuf);
//extern void face_meanluma_calc_ir(char *imgBuf, TsmFaceBox *nirBox, int *meanLuma);
int ifv_kv_load();

int if_vWrite_calib_para(uint16_t *ir2_dep_x2, uint16_t *ir2_dep_y2, uint16_t *ir2_dep_tab2d);
int if_vRead_calib_para(void);
int if_vRrase_calib_para(void);

algo_rectify_output_t* if_vCalibration_check(int h, int w, void *img_l, RectifyPoint *lp,void *img_r, RectifyPoint *rp);
int if_vCalibration_bak(algo_rectify_output_t *result);
int if_vCalibration_state(void);
int if_vCalibration_initial(void);

int ifv_ISP_ir_cis_task_creat(void);
int ifv_ISP_ir_cis_task_delete(void);
int ifv_isp_task_creat(void);
int ifv_isp_task_delete(void);

void if_vFace_ae_clean(void);

void ifv_send_usb_semp(int type);

#endif 
